<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class System_setup extends ZhiyeAdmin_Controller {

    public function __construct(){

        parent::__construct();

		$this->load->model('system_setup_model','system_setup');

    }

	public function index(){
        $search["remarks"]=$_GET['remarks'];
		$where=array();
		if($search["remarks"]!=""){
			array_push($where,"remarks like '%".$search["remarks"]."%'");
		}
		if($search["submit"]==""){
			array_push($where,"system_setup.is_delete =0");
		}
		$page_no = max(intval($page_no),1);
		$this->system_setup->order('id DESC');
		if(count($where)>0)
			$this->system_setup->where($where);
        $data=$this->system_setup
						 ->select_all("system_setup.*",null,null,true,$page_no,"system_setup");
		$data['moudle_name']="系统管理";
		$data['table_name']="System_setup";

		//p($data);die();
		$data['pages']=$this->system_setup->pages($data["total_num"]);
		$data['search']=$search;

        $this->zhiyeAdmin_view("lists", $data);		
        
    }

    public function edit($id=0){
		$data['moudle_name']="系统信息";
		$data['table_name']="System_setup";

		if($id>0){
			$data["system_setup"]=$this->system_setup->select_one($id);
        }
        $this->zhiyeAdmin_view('edit',$data);
        
	}
	public function update($id=0){
		$system_setup=$this->input->post('system_setup');
		if($id>0){
			$this->system_setup->update($system_setup, array('id='.$id));
		}else{
			$this->system_setup->insert($system_setup);
		}
		redirect('admin/system_setup/index');
	}

    public function delete($checkIds=0){
		$checkIds=$_GET['checkIds'];
		$ids = explode(',', $checkIds);
		foreach ( $ids as $id )
		{
			if($id!=''){
                $system['is_delete']=1;
                echo $id;
                echo $system['is_delete'];
                //$this->system_setup->update($system, array('id='.$id));
				$this->system_setup->delete_one($id);
			}
		}
		redirect('admin/system_setup/index');
	}
}